// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter_class2/main.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  // 定义一个widget测试，testWidgets()方法提供了一个WidgetTester用来在测试环境
  // 构建需要测试的组件并与之交互
  testWidgets('一个有自定义title和文本的widget', (WidgetTester tester) async {
    // 通过tester构建待测试的widget
    await tester.pumpWidget(MyApp());

    // 创建finder,找到标题和文本
    final titleFinder = find.text('蛮大的新闻');

    // 使用 flutter_test 提供的 `findsOneWidget` matcher 来匹配一个组件的情况
    // 验证在tree上对应widget是否符合预期
    expect(titleFinder, findsOneWidget);
  });
}
